home *** CD-ROM | disk | FTP | other *** search
/ Champak 43 / Vol 43.iso / games / superdog.swf / scripts / DefineSprite_1217 / frame_2 / DoAction.as
Encoding:
Text File  |  2007-06-25  |  3.0 KB  |  131 lines

  1. function jump()
  2. {
  3.    if(canjump == true and dead == false)
  4.    {
  5.       yinc = -17;
  6.       inAir = true;
  7.       canjump = false;
  8.       acted = false;
  9.    }
  10. }
  11. function moves()
  12. {
  13.    if(dix == false and long >= -500 and dead == false)
  14.    {
  15.       this._x -= movspd;
  16.       long -= movspd;
  17.       this.gotoAndPlay("Φ╡░");
  18.       this._xscale = 100;
  19.    }
  20.    else if(dix == true and long <= 500 and dead == false)
  21.    {
  22.       this._x += movspd;
  23.       long += movspd;
  24.       this.gotoAndPlay("Φ╡░");
  25.       this._xscale = -100;
  26.    }
  27. }
  28. stop();
  29. onEnterFrame = function()
  30. {
  31.    if(_parent._parent.pauses == false)
  32.    {
  33.       if(acted == false and dead == false)
  34.       {
  35.          actnum = random(6);
  36.          acted = true;
  37.       }
  38.       if(acted == true and dead == false)
  39.       {
  40.          act_i++;
  41.          if(act_i >= 60)
  42.          {
  43.             act_i = 0;
  44.             acted = false;
  45.          }
  46.       }
  47.       switch(actnum)
  48.       {
  49.          case 0:
  50.             jump();
  51.             break;
  52.          case 1:
  53.             dix = null;
  54.             moves();
  55.             break;
  56.          case 2:
  57.             dix = false;
  58.             moves();
  59.             jump();
  60.             break;
  61.          case 3:
  62.             dix = true;
  63.             moves();
  64.             jump();
  65.             break;
  66.          case 4:
  67.             dix = false;
  68.             moves();
  69.             break;
  70.          case 5:
  71.             dix = true;
  72.             moves();
  73.       }
  74.       var _loc4_ = 0;
  75.       while(_loc4_ < _parent._parent.item_array.length)
  76.       {
  77.          var _loc3_ = _parent[_parent._parent.item_array[_loc4_]];
  78.          if(this.hitTest(_loc3_) and dead == false)
  79.          {
  80.             delete _loc3_.onEnterFrame;
  81.             _loc3_.manhit = false;
  82.             _loc3_.play();
  83.          }
  84.          _loc4_ = _loc4_ + 1;
  85.       }
  86.       _loc4_ = 0;
  87.       while(_loc4_ < _parent._parent.land_array.length)
  88.       {
  89.          var _loc6_ = _parent[_parent._parent.land_array[_loc4_]];
  90.          if(this.qfk.hitTest(_loc6_) and _loc6_.noWalk == true)
  91.          {
  92.             if(movRight == true)
  93.             {
  94.                this._x += movspd;
  95.             }
  96.             if(movLeft == true)
  97.             {
  98.                this._x -= movspd;
  99.             }
  100.          }
  101.          _loc4_ = _loc4_ + 1;
  102.       }
  103.       if(inAir == true)
  104.       {
  105.          if(yinc < 15)
  106.          {
  107.             yinc += g;
  108.          }
  109.          this._y += yinc;
  110.          _loc4_ = 0;
  111.          while(_loc4_ < _parent._parent.land_array.length)
  112.          {
  113.             landObject = _parent[_parent._parent.land_array[_loc4_]];
  114.             var _loc5_ = landObject.getBounds(_parent).yMin;
  115.             if(this.dfk.hitTest(landObject))
  116.             {
  117.                if(this._y - yinc < _loc5_)
  118.                {
  119.                   inAir = false;
  120.                   this._y = _loc5_;
  121.                   yinc = 0;
  122.                   canjump = true;
  123.                   break;
  124.                }
  125.             }
  126.             _loc4_ = _loc4_ + 1;
  127.          }
  128.       }
  129.    }
  130. };
  131.